package com.qf.dao.impl;

import com.qf.dao.GoodsTypeDao;
import com.qf.entity.GoodsType;
import com.qf.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 10202
 * @version V1.0
 * @Project xiaomi
 * @Package com.qf.dao.impl
 * @Date 2023/4/14 9:41
 */
public class GoodsTypeDaoImpl implements GoodsTypeDao {
    @Override
    public List<GoodsType> selectByLevel(int level) {
        QueryRunner qr=new QueryRunner(DruidUtils.getDataSource());

        try {
            return qr.query("select * from tb_goods_type where level=?",new BeanListHandler<>(GoodsType.class),level);
        } catch (SQLException throwables) {
            throw new RuntimeException(throwables);
        }

    }
}
